/**
  该文件封装了组织架构版块操作的所有接口函数
 */

import http from '@/utils/request'

/**
 * 查询企业的部门列表
 * @returns
 */
export const reqGetDepartments = () => {
  return http({
    url: '/company/department',
    method: 'get'
  })
}

/**
 * 根据ID删除部门
 * @param {string} id
 * @returns
 */
export const reqDelDepartment = (id) => {
  return http({
    url: `/company/department/${id}`,
    method: 'delete'
  })
}

/**
 * 添加一个子部门
 * @param {*} data { pid, name, manager, code, introduce }
 * @returns
 */
export const reqAddDepartment = (data) => {
  return http({
    url: '/company/department',
    method: 'post',
    data
  })
}

/**
 * 根据部门id获取部门详情的数据
 * @param {string} id
 * @returns
 */
export const reqGetDeptDetail = (id) => {
  return http({
    url: `/company/department/${id}`,
    method: 'get'
  })
}

/**
 * 根据id编辑部门
 * @param {*} form {id, ... }
 * @returns
 */
export const reqUpdateDepartDetail = (form) => {
  return http({
    method: 'put',
    url: `/company/department/${form.id}`,
    data: form
  })
}
